package com.cqgcxy.shopping.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;



@WebServlet(urlPatterns="/loginout.do")
public class LogoutServlet extends HttpServlet {

	private static final long serialVersionUID = -815008732191536746L;
	private Logger logger = LoggerFactory.getLogger(getClass());
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
		logger.debug("开始执行dopost方法");
		try {
			//业务处理
			HttpSession session = req.getSession();
			session.invalidate();//清除session中储存的账号密码
			//跳转
			req.getRequestDispatcher("/login.jsp").forward(req, resp);
			logger.debug("退出系统成功");
		}catch (Exception e) {
			req.setAttribute("error", e.getMessage());
			req.getRequestDispatcher("/login.jsp").forward(req, resp);
		}
	}
		
		

	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
	}}

